#pragma once
#include <iostream>
#include "Tcpserver.hpp"
#include "Common.hpp"
#include "Socket.hpp"
// 管理每一个文件描述符
class Tcpserver; // 前置声明
class Connection
{
public:
    Connection() {}
    virtual void Recever() = 0;
    virtual void Sender() = 0;
    virtual void Excepter() = 0;
    void setfd(int fd)
    {
        this->sockfd = fd;
    }
    void setEvents(uint32_t events)
    {
        this->events = events;
    }
    uint32_t getEvents() const
    {
        return events;
    }
    virtual int getFd() 
    {
        return sockfd;
    }
    ~Connection() {}

private:
    int sockfd;
    std::string inbuffer;
    std::string outbuffer;
    // 回指指针
    Tcpserver *owner;
    NetAddr client_addr;
    uint32_t events;
};
